#include "stm32f1xx_hal.h"

//variable------------------------------------------------
unsigned char	CRC_Tab6[6] = {0x15, 0x02, 0x01, 0, 0x44, 0x01};
#define 		Data16  0x8048
unsigned char CRC_H = 0xFF;
unsigned char CRC_L = 0xFF;

//CRC-16------------------------------------------------
uint16_t crc16(uint8_t *_pBuf , uint16_t _usLen)
{  
	uint16_t i;
	unsigned char j;
	unsigned char b_LBS;
	uint16_t u16_CRC_Data = 0xFFFF;
	
	for(i=0;i<_usLen;i++)      
	{

		u16_CRC_Data ^= _pBuf[i];		
		
		for(j=0;j<8;j++)
		{
			b_LBS = u16_CRC_Data & 0x0001;	
			u16_CRC_Data >>= 1;
			if (b_LBS == 1)
			{
				u16_CRC_Data ^= 0x8048;
			}
		}
	}
	u16_CRC_Data ^= 0xFFFF;
	
	return u16_CRC_Data;
}

